package cn.usian.controller;

import cn.usian.pojo.Emp;
import cn.usian.service.EmpService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin(allowedHeaders = "*")
@RequestMapping("/emp")
@RestController
public class EmpController {
    @Autowired
    private EmpService empService;

    //分页查询
    @RequestMapping("findPage")
    public Page<Emp> findPage(@RequestParam(required = true,defaultValue = "1")Integer pageIndex, String name){
        Page<Emp> page =  empService.findPage(pageIndex,name);
        return page;
    }

    //添加
    @RequestMapping("add")
    public void add(@RequestBody Emp emp){
        System.out.println(emp);

        empService.add(emp);
    }

    //删除
    @RequestMapping("del")
    public void del(long id){
        empService.del(id);
    }

}
